//
//  AllArtInfo.m
//  EasyToo
//
//  Created by 郑 哲 on 9/6/13.
//
//

#import "AllArtInfo.h"

@implementation AllArtInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        NSArray *dictJsonArray = GetDictionaryArrayDefaultNil(jsonDictionary, @"perform");
        if (dictJsonArray) {
            self.artList = [[NSMutableArray alloc]init];
            
            for (int i = 0; i < [dictJsonArray count]; i++) {
                NSDictionary *itemDict = [dictJsonArray objectAtIndex:i];
                
                ArtInfo *artInfo = [[ArtInfo alloc] initWithDictionary:itemDict];
                [self.artList addObject:artInfo];
                
            }
        }
     }
    return self;
}
@end



@implementation ArtInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        //解析每一项
        self.ProjectID = GetDictionaryStringDefaultNil(jsonDictionary, @"ProjectID");
        self.PiaoProjectid = GetDictionaryStringDefaultNil(jsonDictionary, @"PiaoProjectid");
        self.ProjectName = GetDictionaryStringDefaultNil(jsonDictionary, @"ProjectName");
        self.PerformName = GetDictionaryStringDefaultNil(jsonDictionary, @"PerformName");
        self.SeatType = GetDictionaryStringDefaultNil(jsonDictionary, @"SeatType");
        self.FieldName = GetDictionaryStringDefaultNil(jsonDictionary, @"FieldName");
        self.Address = GetDictionaryStringDefaultNil(jsonDictionary, @"Address");
        self.PiaoPerformID = GetDictionaryStringDefaultNil(jsonDictionary, @"PiaoPerformID");
        self.PerformTime = GetDictionaryStringDefaultNil(jsonDictionary, @"PerformTime");
        self.PerformID = GetDictionaryStringDefaultNil(jsonDictionary, @"PerformID");
        self.AreaID = GetDictionaryStringDefaultNil(jsonDictionary, @"AreaID");
        self.ImageUrl = GetDictionaryStringDefaultNil(jsonDictionary, @"ImageUrl");
        self.summary = GetDictionaryStringDefaultNil(jsonDictionary, @"summary");
        
        //价格
        NSArray *priceJsonArray = GetDictionaryArrayDefaultNil(jsonDictionary, @"PriceGroup");
        if (priceJsonArray)
        {
            self.priceInfoArray = [[NSMutableArray alloc] init];
            for (int i = 0; i < [priceJsonArray count]; i++)
            {
                NSDictionary *priceDict = [priceJsonArray objectAtIndex:i];
                
                PriceInfo *priceInfo = [[PriceInfo alloc] initWithDictionary:priceDict];
                
                [self.priceInfoArray addObject:priceInfo];
            }
        }
        
    }
    return self;
}

@end


@implementation PriceInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        self.PGradePriceID = GetDictionaryStringDefaultNil(jsonDictionary, @"PGradePriceID");
        self.GradeName = GetDictionaryStringDefaultNil(jsonDictionary, @"GradeName");
        self.Price = GetDictionaryStringDefaultNil(jsonDictionary, @"Price");
        self.Quantity = GetDictionaryStringDefaultNil(jsonDictionary, @"Quantity");

    }
    return self;
}

@end

